package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zeq extends zep {
   private boolean c;
   private int d;
   private int e;
   private long f;
   private zagu[] g;
   private zaar[] h;
   private zagu[][] i;
   private long[][] j;
   private HashMap k;
   private zgk l;

   zeq(zaaz var1, zaay var2) {
      super(var1);
      if (var1.e()) {
         this.c = true;
         if (var1.b()) {
            this.d = -1;
            this.e = -1;
            this.f = -1L;
         } else {
            this.d = var1.b;
            this.e = var1.c;
            this.f = Cell.a(var2.n, this.d, this.e);
         }

         this.g = new zagu[this.a.e()];
      } else {
         this.c = false;
         if (var1.c()) {
            this.d = -1;
            this.e = -1;
            this.f = -1L;
         } else {
            this.d = var1.d;
            this.e = var1.e;
            this.f = Cell.a(var2.n, this.d, this.e);
         }

         this.g = new zagu[this.a.f()];
      }

      this.h = new zaar[this.g.length];
      this.i = new zagu[this.g.length][];
      this.k = new HashMap(8);
      this.j = new long[this.g.length][];
   }

   zagu b(zaay var1) {
      int var2 = this.c ? var1.g - this.a.StartRow : var1.h - this.a.StartColumn;
      if (this.g[var2] == null) {
         zfv var3;
         if (this.c) {
            var3 = var1.d.getCells().getRows().a.a(var1.g, new zfv(this.a.StartColumn - 1), 4);
         } else {
            var3 = var1.d.getCells().getRows().a.a(this.a.StartRow - 1, new zfv(var1.h), 4);
         }

         if (var3 == null) {
            this.g[var2] = zzk.a;
         } else if (var3.c == 5) {
            ArrayList var4 = new ArrayList(8);
            zyi var5 = (zyi)var3.d;
            this.g[var2] = ((zyi)var3.d).a(var1, true);
            if (this.d > -1) {
               this.h[var2] = new zaar();
               this.a(this.g[var2], this.h[var2], this.d, this.e, var1, var4, 0, this.k);
               if (var4.size() > 0) {
                  zagu[] var6 = new zagu[var4.size()];
                  this.i[var2] = var6;

                  for(int var7 = 0; var7 < var6.length; ++var7) {
                     var6[var7] = (zagu)var4.get(var7);
                  }

                  if (this.l != null) {
                     this.j[var2] = this.l.b();
                  }
               } else {
                  this.g[var2].a(false);
               }
            } else {
               this.g[var2].a(false);
            }
         } else {
            this.g[var2] = zaaq.a(var3.c, var3.d);
         }
      }

      int var14;
      if (this.i[var2] != null) {
         zagu[] var9 = this.i[var2];
         int var10 = var9.length;

         for(var14 = 0; var14 < var10; ++var14) {
            zagu var15 = var9[var14];
            var15.a((zaar)null);
         }
      }

      if (this.h[var2] == null && this.j[var2] == null) {
         if (this.c) {
            var1.h = (short)(this.a.StartColumn - 1);
         } else {
            var1.g = this.a.StartRow - 1;
         }
      } else {
         zagu var11;
         if (this.c) {
            var11 = zaaq.a(var1.e, this.a.StartRow - 1, var1.h, false, var1);
            var1.h = (short)(this.a.StartColumn - 1);
         } else {
            var11 = zaaq.a(var1.e, var1.g, this.a.StartColumn - 1, false, var1);
            var1.g = this.a.StartRow - 1;
         }

         if (this.h[var2] != null) {
            this.h[var2].a = var11;
         }

         if (this.j[var2] != null) {
            long[] var12 = this.j[var2];
            var14 = var12.length;

            int var16;
            long var17;
            for(var16 = 0; var16 < var14; ++var16) {
               var17 = var12[var16];
               this.b(var1, var17);
            }

            if (var1.p.G) {
               Object var13 = var1.p.F.get(this.f);
               var1.p.F.put(this.f, var11);
               var11 = this.g[var2].e(var1);
               if (var13 != null) {
                  var1.p.F.put(this.f, var13);
               } else {
                  var1.p.F.remove(this.f);
               }
            } else {
               if (var1.p.F == null) {
                  var1.p.F = new HashMap();
               }

               var1.p.F.put(this.f, var11);
               var1.p.G = true;
               var11 = this.g[var2].e(var1);
               var1.p.F.remove(this.f);
               var1.p.G = false;
            }

            var12 = this.j[var2];
            var14 = var12.length;

            for(var16 = 0; var16 < var14; ++var16) {
               var17 = var12[var16];
               this.b(var1, var17);
            }

            return var11;
         }
      }

      return this.g[var2];
   }

   void a(zaay var1) {
      if (this.j.length >= 1) {
         var1 = new zaay(var1);

         for(int var2 = 0; var2 < this.j.length; ++var2) {
            if (this.j[var2] != null) {
               long[] var3 = this.j[var2];
               int var4 = var3.length;

               for(int var5 = 0; var5 < var4; ++var5) {
                  long var6 = var3[var5];
                  this.c(var1, var6);
               }
            }
         }

      }
   }

   zgi a(int var1, int var2, int var3, zaay var4, HashMap var5) {
      if (this.l == null) {
         this.l = new zgk(var1, var2, var3, var4, var5);
      } else {
         this.l.a();
      }

      return this.l;
   }

   private void b(zaay var1, long var2) {
      var1.p.g.get(zyi.a(var2)).getCells().b.a(zyi.b(var2)).a((byte)0);
      Object var4 = this.k.get(var2);
      if (var4 != zgk.j) {
         long[] var5 = (long[])((long[])var4);
         int var6 = var5.length;

         for(int var7 = 0; var7 < var6; ++var7) {
            long var8 = var5[var7];
            this.b(var1, var8);
         }
      }

   }

   private void c(zaay var1, long var2) {
      this.a(var1, var2);
      Object var4 = this.k.get(var2);
      if (var4 != zgk.j) {
         long[] var5 = (long[])((long[])var4);
         int var6 = var5.length;

         for(int var7 = 0; var7 < var6; ++var7) {
            long var8 = var5[var7];
            this.c(var1, var8);
         }
      }

   }
}
